package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.VisaMaterialRequirementPageQueryDTO;
import com.sky.entity.VisaMaterialRequirement;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface VisaMaterialRequirementMapper {
    /**
     * 新增签证材料要求
     * @param visaMaterialRequirement
     */
    @Insert("insert into visa_material_requirement(product_id, visa_product_name, user_type, material_name, material_detail, is_required, sort_order, create_time, update_time) " +
            "VALUES (#{productId}, #{productName}, #{userType}, #{materialName}, #{materialDetail}, #{isRequired}, #{sortOrder}, #{createTime}, #{updateTime})")
    void insert(VisaMaterialRequirement visaMaterialRequirement);
    
    /**
     * 修改签证材料要求
     * @param visaMaterialRequirement
     */
    void update(VisaMaterialRequirement visaMaterialRequirement);

    /**
     * 删除签证材料要求
     * @param id
     */
    @Delete("delete from visa_material_requirement where id = #{id}")
    void delete(Long id);

    /**
     * 分页查询签证材料要求
     * @param visaMaterialRequirementPageQueryDTO
     * @return
     */
    Page<VisaMaterialRequirement> page(VisaMaterialRequirementPageQueryDTO visaMaterialRequirementPageQueryDTO);

    /**
     * 根据ID查询签证材料要求
     * @param id
     * @return
     */
    @Select("SELECT * FROM visa_material_requirement WHERE id = #{id}")
    VisaMaterialRequirement selectById(Long id);

    /**
     * 根据产品名称查询签证材料要求列表
     * @param productName
     * @return
     */
    @Select("SELECT * FROM visa_material_requirement WHERE visa_product_name = #{productName} ORDER BY sort_order ASC")
    List<VisaMaterialRequirement> selectByProductName(String productName);

    /**
     * 根据产品名称和用户类型查询签证材料要求列表
     * @param productName
     * @param userType
     * @return
     */
    @Select("SELECT * FROM visa_material_requirement WHERE visa_product_name = #{productName} AND user_type = #{userType} ORDER BY sort_order ASC")
    List<VisaMaterialRequirement> selectByProductNameAndUserType(String productName, String userType);

    /**
     * 根据产品ID查询签证材料要求列表
     * @param productId
     * @return
     */
    @Select("SELECT * FROM visa_material_requirement WHERE product_id = #{productId} ORDER BY sort_order ASC")
    List<VisaMaterialRequirement> selectByProductId(Long productId);

    /**
     * 根据产品ID和用户类型查询签证材料要求列表
     * @param productId
     * @param userType
     * @return
     */
    @Select("SELECT * FROM visa_material_requirement WHERE product_id = #{productId} AND user_type = #{userType} ORDER BY sort_order ASC")
    List<VisaMaterialRequirement> selectByProductIdAndUserType(Long productId, String userType);
}
